import * as TYPE from './type';
import {toGet, toPost} from '../../utils/MyAxios';
import {Notice} from 'iview';

/*获取组织机构信息*/
export const getOrganization = ({commit}) => {
  toGet('/human-resources/hr/organ/query')
    .then((response) => {
      if (response.resultCode === 0) {
        let responseData=response.data;
        commit(TYPE.ORGANIZATION, {
          organization:responseData,
        });
      }
      else {
        Notice.error({
          title: '获取组织机构信息失败',
          desc: response.resultMsg
        });
      }
    });
};

/*获取薪酬列表*/
export const getPaymentList = ({commit},params) => {
  toGet('/human-resources/hr/payment/queryAll/'+JSON.stringify(params))
    .then((response) => {
      if (response.resultCode === 0) {
        let responseData=response.data;
        commit(TYPE.PAYMENT, {
          list:responseData.list,
          total:responseData.total,
          currentPage:responseData.currentPage,
          pageSize:responseData.pageSize,
        });
      }
      else {
        Notice.error({
          title: '获取薪酬列表失败',
          desc: response.resultMsg
        });
      }
    });
};
/*获取岗位列表*/
export const getPostSetList = ({commit},params) => {
  toGet('/human-resources/hr/postset/queryAll/'+JSON.stringify(params))
    .then((response) => {
      if (response.resultCode === 0) {
        let responseData=response.data;
        commit(TYPE.POSTSET, {
          list:responseData.list,
          total:responseData.total,
          currentPage:responseData.currentPage,
          pageSize:responseData.pageSize,
        });
      }
      else {
        Notice.error({
          title: '获取岗位列表失败',
          desc: response.resultMsg
        });
      }
    });
};
/*获取员工档案列表*/
export const getStaffList = ({commit},params) => {
  toGet('/human-resources/hr/staff/queryAll/'+JSON.stringify(params))
    .then((response) => {
      if (response.resultCode === 0) {
        let responseData=response.data;
        commit(TYPE.STAFF, {
          list:responseData.list,
          total:responseData.total,
          currentPage:responseData.currentPage,
          pageSize:responseData.pageSize,
        });
      }
      else {
        Notice.error({
          title: '获取员工档案列表失败',
          desc: response.resultMsg
        });
      }
    });
};
